package com.siqi.hr.common.utils.json;

import flexjson.JSONSerializer;

/**
 * Title: <br>
 * Description: <br>
 * Project: 思齐财务管理系统 <br>
 * Date: 2016-4-12
 * 
 * @author xiaoxm
 * @version 1.0
 */
public final class JsonGenerator {

    private JsonGenerator() {
    }

    /**
     * serializer the object into json string
     * @param object the target serialize object
     * @return json string
     */
    public static String serializerObject(Object object) {
        JSONSerializer serializer = new JSONSerializer();
        return serializer.exclude("*.class").serialize(object);
    }

    /**
     * serializer the object into json string, at the sametime include some specified property.
     * @param object object the target serialize object
     * @param propertyName which you specified include into the json string.
     * @return
     */
    public static String serializerObjectInclude(Object object, String... propertyName) {
        JSONSerializer serializer = new JSONSerializer();
        return serializer.exclude("*.class").include(propertyName).exclude("*").serialize(object);
    }

}
